//
//  DXDB.m
//  suremodv
//
//  Created by dd on 13-10-30.
//  Copyright (c) 2013年 xiaomuzhi. All rights reserved.
//

#import "DXDB.h"
#import "DXLog.h"

static FMDatabase *DX_DB;

@implementation DX (DB)

+ getDocumentDBPath:(NSString *)db
{
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *documentsDirectory = [paths objectAtIndex:0];
    NSString *DBPath = [documentsDirectory stringByAppendingPathComponent:db];
    return DBPath;
}

FMDatabase *DXInitDB(NSString *dbPath)
{
    DX_DB = [FMDatabase databaseWithPath:dbPath];
    if (![DX_DB open])
    {
        [DX i:@"open %@ fail", dbPath];
        return nil;
    }
    
    return DX_DB;
}

@end
